package fr.cephb.socialsnp.webapp.form;

import fr.cephb.util.MessageType;

public class ErrorMessage
	{
	private MessageType type;
	private String message;
	public ErrorMessage(String message)
		{
		this(MessageType.ERROR,message);
		}
	
	public ErrorMessage(MessageType type,String message)
		{
		this.type=type;
		this.message=message;
		if(message==null || message.trim().length()==0)
			{
			this.message="ERROR";
			}
		}
	
	public String getMessage() {
		return message;
		}
	
	public MessageType getType() {
		return type;
		}
	
	@Override
	public int hashCode() {
		return getMessage().hashCode();
		}
	
	@Override
	public boolean equals(Object obj) {
		return obj==this;
		}
	
	@Override
	public String toString() {
		return "["+getType()+"]"+getMessage();
		}
	}
